window.KKBus.Ajax = {
    doGet: function(url, successCallback) {
        $.ajax({
            type: "GET",
            url: url,
            timeout: 30000,
            success: successCallback,
            complete: KKBus.Ajax.completeCallback,
            error: KKBus.Ajax.errorCallback
        });
    },
    doPost: function(url, data, successCallback) {
        $.ajax({
            type: "POST",
            url: url,
            timeout: 30000,
            data: data,
            contentType: "application/json",
            dataType: "json",
            success: successCallback,
            complete: KKBus.Ajax.completeCallback,
            error: KKBus.Ajax.errorCallback
        });
    },
    doPut: function(url, data, successCallback) {
        $.ajax({
            type: "PUT",
            url: url,
            timeout: 30000,
            data: data,
            contentType: "application/json",
            dataType: "json",
            success: successCallback,
            complete: KKBus.Ajax.completeCallback,
            error: KKBus.Ajax.errorCallback
        });
    },
    doDelete: function(url, successCallback) {
        $.ajax({
            type: "DELETE",
            url: url,
            timeout: 30000,
            success: successCallback,
            complete: KKBus.Ajax.completeCallback,
            error: KKBus.Ajax.errorCallback
        });
    },
    completeCallback: function(jqXHR, textStatus) {        
        if (app.settings.DEBUG == true) {
            console.log('ajax request complete');
            console.log(jqXHR);
            console.log(textStatus);
        }
    },
    errorCallback: function(jqXHR, textStatus, errorThrown) {
         if (app.settings.DEBUG == true) {
            console.log('ajax request error');
            console.log(jqXHR);
            console.log(textStatus);
            console.log(errorThrown);
        }
    }
};